﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp.装饰器
{
    /// <summary>
    /// 4.3 添加税费 - 具体装饰器
    /// </summary>
    public class TaxDecorator : OrderDecorator
    {
        private readonly double _taxRate;

        public TaxDecorator(IOrder order, double taxRate) : base(order)
        {
            _taxRate = taxRate;
        }

        public override double CalculateTotal()
        {
            double subtotal = base.CalculateTotal();
            return subtotal + (subtotal * _taxRate);
        }
    }
}
